package com.zm.demo.shoppingmall.user.service.impl;

import com.zm.demo.shoppingmall.user.api.UserService;
import com.zm.demo.shoppingmall.user.dao.TUserMapper;
import com.zm.demo.shoppingmall.user.model.TUser;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.time.LocalDateTime;

/**
 * @desc:
 * @author: z01140
 * @date: 2021/5/24 10:39
 */
@Slf4j
@DubboService
public class UserServiceImpl implements UserService {

    @Autowired
    private TUserMapper userMapper;

    @Override
    public int addUser(TUser user) {
        log.info("addUser start, param is {}", user.toString());
        LocalDateTime dateTime = LocalDateTime.now();
        user.setCreateTime(dateTime);
        user.setUpdateTime(dateTime);
        return userMapper.insert(user);
    }

    @Override
    public TUser getUserByMobilePhone(String mobilePhone) {
        return userMapper.getUserByMobilePhone(mobilePhone);
    }

    @Override
    public TUser getUserById(Integer userId) {
        log.info("getUserById ......");
        return userMapper.selectByPrimaryKey(userId);
    }
}
